In [1]:
# Requires Gadfly
using ApproxFun
In [3]:
d=PeriodicInterval()^2
f=Fun((θ,ϕ)->exp(-10(sin(θ/2)^2+sin(ϕ/2)^2)),d)
A=lap(d)+.1I
u=A\f
ApproxFun.contour(u)
Out[3]:
In [4]:
d=PeriodicInterval()*Interval()
g=Fun(z->real(cos(z)),∂(d)) # boundary data
u=[dirichlet(d);lap(d)]\g
ApproxFun.contour(u)
Out[4]:
In [5]:
dθ=PeriodicInterval(-2.,2.);dt=Interval(0,3.)
d=dθ*dt
Dθ=Derivative(d,1);Dt=Derivative(d,2)
u=[I⊗ldirichlet(dt);Dt+Dθ]\Fun(θ->exp(-20θ^2),dθ)
ApproxFun.contour(u)
Out[5]:
We can interchange the variables using .'
In [6]:
A=[ldirichlet(dt)⊗I;(Dt+Dθ).']
f=Fun(θ->exp(-20θ^2),dθ)
u=A\f
ApproxFun.contour(u)
Out[6]:
In [7]:
dθ=PeriodicInterval();dt=Interval(0,2.)
d=dθ*dt
Dθ=Derivative(d,1);Dt=Derivative(d,2)
c=1+Fun(cos,dθ)
#timedirichlet is [u[x,0], u[-1,t], u[1,t]
u=[I⊗ldirichlet(dt);Dt+c*Dθ]\Fun(θ->exp(-20θ^2),dθ)
ApproxFun.contour(u)
Out[7]:
In [8]:
dθ=PeriodicInterval();dt=Interval(0,2.)
d=dθ*dt
Dθ=Derivative(d,1);Dt=Derivative(d,2)
a=Fun(sin,dθ)
#timedirichlet is [u[x,0], u[-1,t], u[1,t]
u=[I⊗ldirichlet(dt);Dt-a*Dθ]\Fun(θ->exp(-20θ^2),dθ)
ApproxFun.contour(u)
Out[8]:
In [9]:
dθ=PeriodicInterval();dt=Interval(0,10.)
d=dθ*dt
ε=.01
Dθ=Derivative(d,1);Dt=Derivative(d,2)
# Parentheses are a hack to get rank 2 PDE
u=[I⊗ldirichlet(dt);Dt-ε*Dθ^2-Dθ]\Fun(θ->exp(-20θ^2),dθ)
ApproxFun.contour(u)
Out[9]:
In [10]:
dθ=PeriodicInterval(-5.,5.);dt=Interval(0,20.)
d=dθ*dt
Dθ=Derivative(d,1);Dt=Derivative(d,2)
# need to specify both ic and its derivative
B=[I⊗ldirichlet(dt);I⊗lneumann(dt)]
u=pdesolve([B;Dt^2-Dθ^2],Fun(θ->exp(-20(θ-.1)^2),dθ),200)
ApproxFun.contour(u)
Out[10]:
In [11]:
dθ=PeriodicInterval(-10.0,2.);dt=Interval(0,.03);
d=dθ*dt
Dθ=Derivative(d,1);Dt=Derivative(d,2)
u=pdesolve([I⊗ldirichlet(dt);Dt+Dθ^3],Fun(θ->exp(-10θ^2),dθ),200)
ApproxFun.contour(u)
Out[11]:
In [12]:
dθ=PeriodicInterval(0.0,1.0);dt=Interval(0,0.03)
d=dθ*dt
Dθ=Derivative(d,1);Dt=Derivative(d,2);
B=[I⊗ldirichlet(dt);I⊗lneumann(dt)]
u=pdesolve([B;Dt^2+Dθ^4],Fun(θ->exp(-200(θ-.5).^2),dθ),200)
ApproxFun.contour(u)
Out[12]: